<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, viewport-fit=cover" name="viewport" />
    <title>回复详情</title>
    <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/2.4.1/weui.min.css">
    <style>
        #content_div{
            overflow-x: scroll;
        }
    </style>
</head>
<body>

<script type="text/x-dot-template" id="template">
    <div class="page__bd">
        <article class="weui-article">
            <section>
                <section>
                    <h3>{{=it.topic.id}}、{{=it.topic.title}}</h3>
                    <p></p>
                    <div id="content_div">{{=it.content}}</div>
                    <ul class="weui-media-box__info">
                        <li class="weui-media-box__info__meta">{{=it.created_at}}</li>
                        <li class="weui-media-box__info__meta weui-media-box__info__meta_extra">阅读{{=it.read_count}}</li>
                        <li class="weui-media-box__info__meta weui-media-box__info__meta_extra" onclick="fnOpenTopicRepliesPage('{{=it.id}}')">评论{{=it.reply_count}}</li>
                    </ul>
                </section>
            </section>
        </article>
    </div>
</script>

</body>

<script type="text/javascript" src="../js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="../js/doT.min.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript">
    $().ready(function () {
        fnGetTopic();
    });

    function fnGetTopic() {
        var id = fnGetUrlQueryString('id');
        $.ajax({
            url: base_request_url + 'replies/' + id,
            type: 'get',
            success: function (res) {
                console.log(res)
                if (res.code == '0') {

                    var tmpltxt = doT.template(document.getElementById("template").innerHTML);//生成模板方法
                    var html = tmpltxt(res.data); // 数据渲染
                    $('body').append(html);

                } else {
                    alert(res.msg);
                }
            }
        })
    }

    function fnOpenTopicRepliesPage(topic_id) {
        window.location.href = '../replies/index.html?topic_id=' + topic_id;
    }
</script>
</html>
